const mongoose = require('mongoose');

const postSchema = new mongoose.Schema({
  title: { type: String, required: true },
  content: { type: String, required: true },
  author: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
  petType: { type: String, required: true },
  price: { type: Number, required: true },
  location: { type: String, required: true },
  startDate: { type: Date, required: true },
  endDate: { type: Date, required: true },
  contactInfo: {
    phone: String,
    wechat: String
  },
  isActive: { type: Boolean, default: true },
  status: { 
    type: String, 
    enum: ['pending', 'paid', 'in_progress', 'completed', 'cancelled'],
    default: 'pending' 
  },
  paymentId: { type: mongoose.Schema.Types.ObjectId, ref: 'Payment' },
  fosterUser: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, // 收养人
  createdAt: { type: Date, default: Date.now }
});

module.exports = mongoose.model('Post', postSchema);